package com.bolingcavalry.crm.taskorder.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.entity.taskorder.TaskOrder;
import com.vo.TaskOrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface TaskorderMapper extends BaseMapper<TaskOrder> {
    @Select("select * from task_orders where id = #{id}")
    TaskOrder selectByIda(Long id);

    boolean updateStatus(Long id, String status);

    void setisdeleted(Long id);

    @Select("SELECT id FROM task_orders WHERE task_order_number = #{orderNumber} and is_deleted=1")
    Long selectIdByOrderNumber(String orderNumber);

    IPage<TaskOrderVO> getTaskOrdersByPage(IPage<TaskOrderVO> page,
                                           @Param("customerName") String customerName,
                                           @Param("technicalManagerName") String technicalManagerName,
                                           @Param("businessManagerName") String businessManagerName,
                                           @Param("receiverName") String receiverName,
                                           @Param("taskOrderNumber") String taskOrderNumber,
                                           @Param("startDate") String startDate,
                                           @Param("endDate") String endDate,
                                           @Param("status") String status,
                                           @Param("currentUsername") String currentUsername);

    @Select("SELECT * FROM task_orders WHERE task_order_number = #{taskOrderNumber} and is_deleted=1")
    TaskOrder selectByOrderNumber(String taskOrderNumber);

    void updateStatusByOrderNumber(String orderNumber, String status);

    boolean getByOrderNumberToDown(String taskOrderNumber);

    boolean selectByTaskOrderNumber(String taskOrderNumber);

    int getOrderCount(String taskOrderNumber);
}
